package com.jrx.anytxn.investor.timer.job.transfer.step;

import com.jrx.anytxn.investor.entity.TlFundTransferLog;
import com.jrx.anytxn.investor.mapper.ext.ExtTlFundTransferLogMapper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemWriter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 放款writer
 */
@Service
public class TransferWriter implements ItemWriter<TlFundTransferLog> {

    private static final Logger logger = LoggerFactory.getLogger(TransferWriter.class);

    @Resource
    private ExtTlFundTransferLogMapper ExtTlFundTransferLogMapper;

    @Override
    public void write(List items) {


        List<TlFundTransferLog> updateLogList = new ArrayList<>();

        for (Object item : items) {
            TlFundTransferLog updateLog = (TlFundTransferLog) item;
            if (null != updateLog) {
                updateLogList.add(updateLog);
            }
        }

        if (CollectionUtils.isNotEmpty(updateLogList)) {
            ExtTlFundTransferLogMapper.batchUpdateForBatch(updateLogList);
        }
    }
}
